<%@ Page Language="C#" MasterPageFile="~/admin/EMP/EMPMP.master" AutoEventWireup="true" CodeFile="customer.aspx.cs" Inherits="admin_EMP_customer" Title="Customer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="body_page" Runat="Server">
    Search
    <asp:TextBox ID="txtSearchValue" runat="server"></asp:TextBox>
    By<asp:DropDownList ID="ddlSearchType" runat="server">
        <asp:ListItem Value="NumberID">Number ID</asp:ListItem>
        <asp:ListItem>Name</asp:ListItem>
        <asp:ListItem>Address</asp:ListItem>
        <asp:ListItem>Phone</asp:ListItem>
    </asp:DropDownList>
    <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
    <asp:Button ID="Button2" runat="server" Text="All customer" OnClick="Button2_Click" />
    <asp:Button ID="Button3" runat="server" Text="Create customer" OnClick="Button3_Click"  />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" CssClass="table" DataKeyNames="UserID" DataSourceID="dsCustomer"
        Width="100%">
        <Columns>
            <asp:TemplateField HeaderText="User Name" SortExpression="UserName">
                <ItemTemplate>
                    <%# "<a href=customer.aspx?uid=" + Eval("UserID").ToString() + ">" + Eval("UserName").ToString() + "</a>"%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="BranchName" HeaderText="Branch Name" SortExpression="BranchName" />
            <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
            <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
            <asp:BoundField DataField="NumberID" HeaderText="Number ID" SortExpression="NumberID" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:BoundField DataField="CreatedDate" HeaderText="Created Date" SortExpression="CreatedDate" />
            <asp:BoundField DataField="Trangthai" HeaderText="Status" SortExpression="Trangthai" />
             
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="dsCustomer" runat="server" ConnectionString="<%$ ConnectionStrings:ketnoi2 %>"
        SelectCommand="
SELECT     dbo.Branches.*, dbo.Users.*,Trangthai=
    case 
	        when Users.Status=1 then 'OK'
	        when  Users.Status=0 then 'NotOK'
    end  
FROM         dbo.Branches INNER JOIN
                      dbo.Users ON dbo.Branches.BranchID = dbo.Users.BranchID
where (Users.[Level] = @Level)">
        <SelectParameters>
            <asp:Parameter DefaultValue="3" Name="Level" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Panel ID="pnEditCustomer" runat="server" Height="50px" Width="100%" Visible="False">
        <table class="table2" style="width: 100%">
        <tr>
                <td style="width: 30%">
                    User ID</td>
                <td style="width: 70%">
                    <asp:TextBox ID="txtUserID" runat="server" Width="100%" Enabled=false></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 30%">
                    First Name</td>
                <td style="width: 70%">
                    <asp:TextBox ID="txtFname" runat="server" Width="100%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 30%">
                    Last Name</td>
                <td style="width: 70%">
                    <asp:TextBox ID="txtLname" runat="server" Width="100%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 30%; height: 27px;">
                    Phone</td>
                <td style="width: 70%; height: 27px;">
                    <asp:TextBox ID="txtPhone" runat="server" Width="100%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 30%">
                    Address</td>
                <td style="width: 70%">
                    <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" Width="100%"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 30%">
                </td>
                <td style="width: 70%">
                    <asp:Button ID="Button4" runat="server" Text="Update" OnClick="Button4_Click" />
                    <asp:Label ID="lblThongbao" runat="server"></asp:Label></td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>

